package com.guigu.mq.callback;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

/**
 * @ClassName:ConfirmCallback
 * @Description://TODO
 * @Author:taoLong
 * @Date:2021/11/4:14:41 星期四
 * @email:2391611102@qq.com or 2391611102qq@gmail.com
 */
@Component
@Slf4j
public class ConfirmCallback implements RabbitTemplate.ConfirmCallback {
    @Override
    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
        String id = correlationData != null ? correlationData.getId() : "";
        if (ack)
            log.info("消息应答成功!");
        else
            log.error("消息应答失败,失败原因为:{}", cause);
    }
}
